package utgame.com.basedemo;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

public class BaseActivity extends AppCompatActivity {

    private TextView mTvLog;

    /**
     * set screen view
     * @param layoutResID
     */
    public void baseSetContentView(int layoutResID){

//        mFileContentView = (TextView) findViewById(R.id.tvLog);
//        mFileContentView.setMovementMethod(ScrollingMovementMethod.getInstance());
        setContentView(R.layout.activity_base);

        mTvLog = (TextView)findViewById(R.id.tvLog);

        LinearLayout llContent = (LinearLayout)
                findViewById(R.id.ll_content); //v_content是在基类布局文件中预定义的layout区域

        //通过LayoutInflater填充基类的layout区域
        LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View v = inflater.inflate(layoutResID, null);
        llContent.addView(v);

    }

    protected void writeLog(String strLog, boolean isAppend){

        if (isAppend){
            mTvLog.append(strLog);
        } else {
            mTvLog.setText(strLog);
        }
    }

}
